<!DOCTYPE html>
<html lang="zh">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
<title>登录页面  - 鹊桥</title>
<link rel="icon" href="favicon.ico" type="image/ico">
<meta name="keywords" content="鹊桥,内网穿透">
<meta name="description" content="鹊桥">
<meta name="author" content="jiucheng">
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/materialdesignicons.min.css" rel="stylesheet">
<link href="css/style.min.css" rel="stylesheet">
<style>
.lyear-wrapper {
    position: relative;
}
.lyear-login {
    display: flex !important;
    min-height: 100vh;
    align-items: center !important;
    justify-content: center !important;
}
.login-center {
    background: #fff;
    min-width: 29.25rem;
    padding: 2.14286em 3.57143em;
    border-radius: 5px;
    margin: 2.85714em;
}
.login-header {
    margin-bottom: 1.5rem !important;
}
.login-center .has-feedback.feedback-left .form-control {
    padding-left: 38px;
    padding-right: 12px;
}
.login-center .has-feedback.feedback-left .form-control-feedback {
    left: 0;
    right: auto;
    width: 38px;
    height: 38px;
    line-height: 38px;
    z-index: 4;
    color: #dcdcdc;
}
.login-center .has-feedback.feedback-left.row .form-control-feedback {
    left: 15px;
}
</style>
</head>
  
<body>
<div class="row lyear-wrapper">
  <div class="lyear-login">
    <div class="login-center">
      <div class="login-header text-center">
        <a href="login"> <img alt="light year admin" src="images/logo-sidebar.png"> </a>
      </div>
      <form action="#!" method="post">
        <div class="form-group has-feedback feedback-left">
          <input type="text" placeholder="请输入邮箱" class="form-control" name="username" id="username" />
          <span class="mdi mdi-account form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left">
          <input type="password" placeholder="请输入密码" class="form-control" id="password" name="password" />
          <span class="mdi mdi-lock form-control-feedback" aria-hidden="true"></span>
        </div>
        <div class="form-group has-feedback feedback-left row">
          <div class="col-xs-7">
            <input id="captcha" type="text" name="captcha" class="form-control" placeholder="验证码">
            <span class="mdi mdi-check-all form-control-feedback" aria-hidden="true"></span>
          </div>
          <div class="col-xs-5">
            <img src="kaptcha" class="pull-right" id="captcha" style="cursor: pointer; width: 120px" onclick="this.src='kaptcha?r='+Math.random();" title="点击刷新" alt="captcha">
          </div>
        </div>
        <div class="form-group">
          <button class="btn btn-block btn-primary" type="button" id="letsgo">登录</button>
        </div>
        <#
         if($githubOpened == "T")
         #>
        <div class="form-group">
            <span>&equiv;&nbsp;</span>
            <a title="github登陆" href="oauth2/goto?type=github"><img alt="github" src="images/github.svg" height="20px"></a>
        </div>
        <#
        fi;
         #>
      </form>
      <hr>
      <footer class="col-sm-12 text-center">
        <p class="m-b-0">Copyright © 2020 <a href="http://blog.jiucheng.org">旧城</a>. All right reserved</p>
      </footer>
    </div>
  </div>
</div>
<script type="text/javascript" src="js/jquery.min.js"></script>
<script type="text/javascript" src="js/bootstrap.min.js"></script>
<script src="js/bootstrap-notify.min.js"></script>
<script type="text/javascript" src="js/lightyear.js"></script>
<script type="text/javascript" src="js/jquery.cookie.js"></script>
<script type="text/javascript">
$('#letsgo').on('click', function(){
	if ($('#username').val() == '') {
		lightyear.notify('邮箱不能为空', 'danger', 1000);
		return;
	}
    if ($('#password').val() == '') {
        lightyear.notify('密码不能为空 ', 'danger', 1000);
        return;
    }
    if ($('#captcha').val() == '') {
        lightyear.notify('验证码不能为空', 'danger', 1000);
        return;
    }
    if ($('#captcha').val().toLowerCase() != $.cookie('kaptcha').toLowerCase()) {
        lightyear.notify('验证码错误', 'danger', 1000);
        return;
    }
    lightyear.loading('show');
    $.ajax({
        type: "POST",
        url: "/openapi/v1/login",
        contentType: "application/json;charset=utf-8",
        data:JSON.stringify({"username":$('#username').val(),"password":$('#password').val()}),
        dataType: "json",
        success:function (message) {
            lightyear.loading('hide');
            if (message.sta == 0) {
            	console.log(message.obj);
                // lightyear.notify('登陆成功，页面即将自动跳转~', 'success', 1000);
                location.href = "index?utm_source=/login";
            } else {
            	lightyear.notify(message.msg, 'danger', 1000);
            }
        },
        error:function (message) {
            lightyear.loading('hide');
            lightyear.notify('服务器错误，请稍后再试~', 'danger', 100);
        }
    });
});
</script>
</body>
</html>